/*
* ssm_constants.h 
* Feb. 10,  2006
* John Kapenga, john@cs.wmich.edu 
* Constants and coversion for different units
*/
#include <math.h>

// UNITS Used in internal computations in the sunseeker models 
//  Distance, M meter                              (
//  Time, S second 
//  Mass, Kg kilogram
//  Voltage, V volts
//  Current, A amps
//  Force, N newton   (N = Kg M / S^2)  
//  Power, W watt     (W = V * A = N * M / S)
//  Energy, J Joule   (J = N * M = W * S)
//  Angle, Rad radian

// Some conversion to other units.
//  Hour H = 3600 S  
//  Pound (weight) LB = 4.448 N  (approximate)
//  Pound (mass) 2.209 LB = 1 KG  (approximate)
//  Killogram (force sic.) = 9.80665 Newton (approximate)
//  Degree  (360  deg = 2 * Pi  Rad)
//  KM / H  (KM / H =  1000/3600  M / S)
//  IN = 2.54 CM (exact?)
//  Mile ( MI = 1.609 KM)  (approximate)
//  Mile / Hour (MI/H = 1.609 Km/H = 0.447 M/S)  (approximate)
//  Horsepower (HP = 745.7 W)  (approximate)
//  Watt Hour ( W * H = 3600 J = 3600 W * S)

// Conversion Macros
//
// Except Newtons to Killograms and Horsepower to Watts the following are all
// based on 2.54 Centimeters per Inch. Which may now be considered "exact" (NIST).
//
// Note there are several differenet definitions of Hoursepower:
//   horsepower (550 ft lbf/s)   watt (W)   7.456999 E+02 used below
//   horsepower (boiler)         watt (W)   9.80950  E+03
//   horsepower (electric)       watt (W)   7.46     E+02
//   horsepower (metric)         watt (W)   7.354988 E+02
//   horsepower (U.K.)           watt (W)   7.4570   E+02
//   horsepower (water)          watt (W)   7.46043  E+02
//
// In general, pounds (mass) is not equal to pounds (weight). In Newtons to 
// Killograms below the "standard" force of gravity is assumed.
//
// All conversions are designed to be "invertable", (eg ATOB*BTOA == 1.0) up to
// double precision accuracy. Since "all" compilers will precompute constant
// expressions, this will introduce no extra run time costs.
//
// Miles / Hour to Meters / Second
#define MIPHTOMPS (5280.0*12.0*CMTOIN/100.0/3600.0)
// Killometers / Hour to Meters / Second
#define KMPHTOMPS (1000.0/3600.0)
// Meters / Second to Miles / Hour
#define MPSTOMIPH (1.0/MIPHTOMPS)
// Meters / Second to Killometers / Hour
#define MPSTOKMPH (1.0/KMPHTOMPS)
// Miles / Hour to Killometers / Hour
#define MIPHTOKMPH (KMPHTOMPS*MPSTOMIPH)
// Killometers / Hour to Miles / Hour
#define KPHTOMIPH (1.0/MIPHTOKMPH)
//
// Gravatational accelleration of free fall M/S^2 (NIST standard value)
#define G_N 9.80665
//
// Newtons Pounds (weight)
// NIST: If the local value of the acceleration of free fall is taken 
// as g_n = 9.80665 M/S^2 (the standard value)
#define LBTON 4.4482216152605
#define NTOLB (1.0/LNTON)
//
// Pounds (mass) Killogram 
// (NIST: exact for avoirdupois pound)
#define LBTOKG 0.45359237
#define KGTOLB (1.0/LBTOKG)
//
// Killograms (force sic.) Newtons
// (See Newton Pounds (weight) above. here KGTON is g_n = 9.80665)
#define KGTON (KGTOLB*LBTON)
#define NTOKG (1.0/KGTON)
//
// Inches Centimeters
// (NIST  2.54 CM per Inch exact?, is the base most of the constants here)
#define INTOCM 2.54
#define CMTOIN (1.0/INTOCM)
//
// Miles Killometers
#define MITOKM (5280.0*12.0*INTOCM/100.0/1000.0)
#define KMTOMI (1.0/MITOKM)
//
// Degrees Radians
#define DEGTORAD (M_PI/180.0)
#define RADTODEG (180.0/M_PI)
//
// Watts Hourspower 
// (approximate)
#define HPTOW 745.6999 
#define WTOHP (1.0/HPTOW)
//
// Degree C  Degree F
#define CTOF(c) (1.8*c+32.0) 
#define FTOC(f) ((f-32.0)/1.8)
//
// Hour Second
#define HTOS 3600.0
#define STOH (1.0/HTOS)
//
// Killo Unit  Unit
#define KUTOU 1000.0
#define UTOKU (1.0/KUTOU)
// Centi Unit  Unit
#define UTOCU 100.0
#define CUTOU (1.0/UTOCU)
